from pyecharts import options as opts
from pyecharts.charts import Line

# 示例数据，实际使用时需要替换为真实数据
months = ["2023-01", "2023-02", "2023-03", "2023-04", "2023-05", "2023-06", "2023-07", "2023-08", "2023-09", "2023-10", "2023-11", "2023-12"]
prices = [3000, 3050, 3100, 3150, 3200, 3250, 3300, 3350, 3400, 3450, 3500, 3550]

# 创建折线图
line_chart = (
    Line()
    .add_xaxis(months)
    .add_yaxis("房价", prices)
    .set_global_opts(
        title_opts=opts.TitleOpts(title="2023年某地房价走势",pos_left="center",pos_bottom="1%"),
        xaxis_opts=opts.AxisOpts(name="月份"),
        yaxis_opts=opts.AxisOpts(name="房价（元/平方米）"),
        #配置图例
        legend_opts=opts.LegendOpts(is_show=True)
    )
)

# 渲染图表
line_chart.render()
